<style>
.{{$t|escape:'html'}}_main {
  border-left: 15px solid #eaf2f5;
  border-right: 15px solid #eaf2f5;
  width: 1200px;
}
.{{$t|escape:'html'}}_subtitle {
  background-color: #e5f1f5;
  padding: 7px 0 7px 10px;
  font-family: Arial Black;
}
.{{$t|escape:'html'}}_emphasis {
  background-color: #d6e3e8;
  font-weight: bold;
  font-family: Trebuchet MS;
}
table.{{$t|escape:'html'}}_pagecreate {
}
table.{{$t|escape:'html'}}_pagecreate td.title {
  font-weight: bold;
  text-align: right;
  padding: 2px 10px 2px 20px;
  margin-right: 20px;
  background-color: #d6e3e8;
  font-family: Trebuchet MS;
  width: 150px;
  height: 30px;
}
table.{{$t|escape:'html'}}_pagecreate td.content {
  width: 400px;
}
.{{$t|escape:'html'}}_select {
  width: 195px;
  height: 23px;
  margin-left: 4px; 
}

.{{$t|escape:'html'}}_text {
  width: 275px;
  height: 20px;
  margin-left: 4px;
}
.{{$t|escape:'html'}}_textarea {
  width: 275px;
  height: 80px;
  margin-left: 4px;
}
.{{$t|escape:'html'}}_button {
  margin-top: 10px; 
  margin-left: 3px; 
}

table.{{$t|escape:'html'}}_list {
  border-left: 1px solid #dddddd;
  border-top: 1px solid #dddddd;
  margin-bottom: 1px;
  font-size: 11px;
}
table.{{$t|escape:'html'}}_list td.border {
  border-right: 1px solid #dddddd;
  border-bottom: 1px solid #dddddd;
}
table.{{$t|escape:'html'}}_list th {
  text-align: left;
  height: 35px;
  background-color: #eaf2f5;
  padding: 5px 0 5px 10px; 
  border-right: 1px solid #ffffff;
  border-bottom: 1px solid #ffffff;
}
table.{{$t|escape:'html'}}_list tr.drop td {
  padding-left: 0;
  border-right: 0;
  border-bottom: 0;
}
table.{{$t|escape:'html'}}_list tr.hi td {
  padding-left: 10px;
  height: 35px;
  background-color: #ff8000;
  border-right: 1px solid #ff8000;
  border-bottom: 1px solid #ff8000;
  cursor: move;
}
table.{{$t|escape:'html'}}_list tr.rowodd td {
  padding-left: 10px;
  height: 35px;
  background-color: #eeeeee;
  border-right: 1px solid #dddddd;
  border-bottom: 1px solid #dddddd;
}
table.{{$t|escape:'html'}}_list tr.roweven td {
  padding-left: 10px;
  height: 35px;
  border-right: 1px solid #dddddd;
  border-bottom: 1px solid #dddddd;
}
table.{{$t|escape:'html'}}_list tr.rowodd:hover td {
  background-color: #f4f3b2;
}
table.{{$t|escape:'html'}}_list tr.roweven:hover td {
  background-color: #f4f3b2;
}
</style>
<div class="{{$t|escape:'html'}}_main">
  <div>
    <div class="{{$t|escape:'html'}}_subtitle" style="text-align: center;background-color: #eaf2f5;">
      <span class="image_button" style="width: 100px;" onclick="save();">
        <table>
          <tr>
            <td><img src="image/btn/save24.png"></img></td>
            <td>{{t escape='html'}}Save{{/t}}</td>
          </tr>
        </table>
      </span>
    </div>
  </div>
  <div class="{{$t|escape:'html'}}_subtitle">{{t escape='html'}}Basic Information{{/t}}</div>
  <table class="{{$t|escape:'html'}}_pagecreate">
    <tr>
      <td class="title">{{t escape='html'}}Admin Account{{/t}}</td>
      <td class="content"><input onchange="_object._account = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if isset($profile->user)}}{{$profile->user->account|escape:'html'}}{{else}}{{$profile->account|escape:'html'}}{{/if}}"></input></td>
      <td class="title">{{t escape='html'}}Admin Email{{/t}}</td>
      <td class="content"><input onchange="_object._email = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if isset($profile->user)}}{{$profile->user->email|escape:'html'}}{{else}}{{$profile->email|escape:'html'}}{{/if}}"></input></td>
    </tr>
    <tr>
      <td class="title">{{t escape='html'}}Admin Password{{/t}}</td>
      <td class="content"><input onchange="_object._newpass = this.value;" type="password" class="{{$t|escape:'html'}}_text" value="{{if isset($profile->user)}}{{$profile->user->password|escape:'html'}}{{else}}{{$profile->password|escape:'html'}}{{/if}}"></input></td>
      <td></td>
      <td></td>
    </tr>
  </table>
  <div class="{{$t|escape:'html'}}_subtitle">{{t escape='html'}}SEO Details{{/t}}</div>
  <table class="{{$t|escape:'html'}}_pagecreate">
    <tr>
      <td class="title">{{t escape='html'}}Title{{/t}}</td>
      <td class="content"><input onchange="_profile.title = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if !empty($profiles)}}{{$profiles[0]->title|escape:html}}{{/if}}"></input></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td class="title">{{t escape='html'}}Description{{/t}}</td>
      <td class="content"><textarea onchange="_profile.desc = this.value;" class="{{$t|escape:'html'}}_textarea">{{if !empty($profiles)}}{{$profiles[0]->desc|escape:html}}{{/if}}</textarea></td>
      <td class="title">{{t escape='html'}}Key Words{{/t}}</td>
      <td class="content"><textarea onchange="_profile.keywords = this.value;" class="{{$t|escape:'html'}}_textarea">{{if !empty($profiles)}}{{$profiles[0]->keywords|escape:html}}{{/if}}</textarea></td>
    </tr>
  </table>
  <div class="{{$t|escape:'html'}}_subtitle">{{t escape='html'}}Mailing Server{{/t}}</div>
  <table class="{{$t|escape:'html'}}_pagecreate">
    <tr>
      <td class="title">{{t escape='html'}}Host{{/t}}</td>
      <td class="content"><input onchange="_profile.mail_host = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if !empty($profiles)}}{{$profiles[0]->mail_host|escape:html}}{{/if}}"></input></td>
      <td class="title">{{t escape='html'}}SMTP AUTH{{/t}}</td>
      <td class="content"><input onchange="_profile.mail_SMTPAuth = (this.checked) ? 1 : 0;" type="checkbox" {{if !empty($profiles) && $profiles[0]->mail_SMTPAuth == 1}}checked="1"{{/if}}></td>
    </tr>
    <tr>
      <td class="title">{{t escape='html'}}Account{{/t}}</td>
      <td class="content"><input onchange="_profile.mail_account = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if !empty($profiles)}}{{$profiles[0]->mail_account|escape:html}}{{/if}}"></input></td>
      <td class="title">{{t escape='html'}}Sender's Mail{{/t}}</td>
      <td class="content"><input onchange="_profile.mail_from_mail = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if !empty($profiles)}}{{$profiles[0]->mail_from_mail|escape:html}}{{/if}}"></input></td>
    </tr>
    <tr>
      <td class="title">{{t escape='html'}}Password{{/t}}</td>
      <td class="content"><input onchange="_profile.mail_password = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if !empty($profiles)}}{{$profiles[0]->mail_password|escape:html}}{{/if}}"></input></td>
      <td class="title">{{t escape='html'}}Sender's Name{{/t}}</td>
      <td class="content"><input onchange="_profile.mail_from_name = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if !empty($profiles)}}{{$profiles[0]->mail_from_name|escape:html}}{{/if}}"></input></td>
    </tr>
  </table>
  <div class="{{$t|escape:'html'}}_subtitle">{{t escape='html'}}Google App{{/t}}</div>
  <table class="{{$t|escape:'html'}}_pagecreate">
    <tr>
      <td class="title">{{t escape='html'}}Analytics Code{{/t}}</td>
      <td class="content"><input onchange="_profile.analytics_code = this.value;" type="text" class="{{$t|escape:'html'}}_text" value="{{if !empty($profiles)}}{{$profiles[0]->analytics_code|escape:html}}{{/if}}"></input></td>
      <td></td>
      <td></td>
    </tr>
  </table>
  <div id="{{$t|escape:'html'}}_manage_user" style="{{if isset($profile->user)}}display: none{{else}}display: block{{/if}}">
  <div class="{{$t|escape:'html'}}_subtitle">{{t escape='html'}}Manage User{{/t}}</div>
  <table id="{{$t|escape:'html'}}_users" class="{{$t|escape:'html'}}_list" cellPadding="0" cellSpacing="0">
    <tr>
      <td style="height: 35px;padding-left: 10px;"><input id="{{$t|escape:'html'}}_users_select" type="checkbox"></input></td>
      <td class="border" style="padding-left: 10px;border-bottom: 0;" colSpan=5>
        <table>
          <tr>
            <td><select id="{{$t|escape:'html'}}_users_actions"><option>{{t escape='html'}}Actions...{{/t}}</option></select></td>
            <td>
              <span class="image_button" style="width: 140px;" onclick="location.href='admin.php?t=profile_user';">
                <table>
                  <tr>
                    <td><img src="image/btn/add.png"></img></td>
                    <td>{{t escape='html'}}New User{{/t}}</td>
                  </tr>
                </table>
              </span>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <th width="50px"></th>
      <th width="200px">{{t escape='html'}}Account{{/t}}</th>
      <th width="350px">{{t escape='html'}}Email{{/t}}</th>
      <th width="100px"></th>
    </tr>
  </table>
  </div>
  <div>
    <div class="{{$t|escape:'html'}}_subtitle" style="text-align: center;background-color: #eaf2f5;">
      <span class="image_button" style="width: 100px;" onclick="save();">
        <table>
          <tr>
            <td><img src="image/btn/save24.png"></img></td>
            <td>{{t escape='html'}}Save{{/t}}</td>
          </tr>
        </table>
      </span>
    </div>
  </div>
</div>

{{*/* Javascript */*}}
<script src="jsrequest.php?script={{$t|escape:'html'}}" type="text/javascript"></script>
<script type="text/javascript">
  <!--
    if (document.addEventListener) {
      document.addEventListener('DOMContentLoaded', init, false);
    }
    window.onload = init;
    
    var _profiles = JSON.parse('{{$profiles|@json_encode|escape:'javascript'}}');
    var _users = JSON.parse('{{$users|@json_encode|escape:'javascript'}}');
    var _p = JSON.parse('{{$profile|@json_encode|escape:javascript}}');
    var _p_user = (_p.user) ? _p.user : null;
    var _profile = (_profiles.length > 0) ? _profiles[0] : pz_profile.instance();
    var _object = {};
    var _move = null;
    var _y = 0;
    var _selects = [];
    
    function init() {
      if (!document.getElementById || !document.createElement || !arguments || arguments.callee._loaded) {
        return;
      }
      arguments.callee._loaded = true;
      
      if (!_p_user) {
        update_users_table();
        
        var select, actions;
        select = document.getElementById('{{$t|escape:'html'}}_users_select');
        select.onclick = function() {
          for (var idx in  _selects) {
            var obj = _selects[idx];
            if (obj._obj.is_custom == 0) {
              continue;
            }
            obj.checked = this.checked;
          }
        };
        actions = document.getElementById('{{$t|escape:'html'}}_users_actions');
        actions.options[actions.options.length] = new Option('{{t escape='javascript'}}Delete{{/t}}');
        actions.onchange = function() {
          if (this.selectedIndex == 1) {
            var deletes = [];
            for (var idx in  _selects) {
              var obj = _selects[idx];
              if (obj.checked) {
                deletes[deletes.length] = obj._obj;
              }
            }
            new RequestUtils()._custom('delete_users', JSON.stringify(deletes), function(result, params) {
              for (var idx in  deletes) {
                var obj = deletes[idx];
                MiscUtils.remove(_users, obj, null);
              }
              update_users_table();
              actions.selectedIndex = 0;
            }, {
              pos : DOMUtils.findPos(this)
            });
          }
        };
      }
    }
    
    function update_users_table() {
      var table, tr, td, elm, div, p;
      
      table = document.getElementById('{{$t|escape:'html'}}_users');
      DOMUtils.removeTableRows(table, 2);
      if (_users.length == 0) {
        tr = table.insertRow(-1);
        tr.className = 'nohover';
        td = tr.insertCell(-1);
        td.className = 'border';
        td.colSpan = 5;
        td.style.padding = '5px 0 5px 10px';
        td.style.height = '35px';
        td.appendChild(document.createTextNode('{{t escape='javascript'}}No Results Found{{/t}}'));
        
      } else {
        for (var idx in _users) {
          var obj = _users[idx];
          
          tr = table.insertRow(-1);
          tr.className = (idx % 2 == 1) ? 'rowodd' : 'roweven';
          
          td = tr.insertCell(-1);
          elm = document.createElement('input');
          elm.type = 'checkbox';
          elm._obj = obj;
          _selects.push(elm);
          td.appendChild(elm);
          
          td = tr.insertCell(-1);
          td.appendChild(document.createTextNode(obj.account));
          td = tr.insertCell(-1);
          td.appendChild(document.createTextNode(obj.email));
          td = tr.insertCell(-1);
          elm = document.createElement('img');
          elm.src = 'image/edit.png';
          elm.style.cursor = 'pointer';
          elm._obj = obj;
          elm.onclick = function() {
            location.href = '?t=profile_user&i=' + this._obj.id;
          };
          td.appendChild(elm);
        }
      }
    }
    
    function save() {
      if (!_p_user) {
        _profile.account = (_object._account) ? _object._account : _profile.account;
        _profile.email = (_object._email) ? _object._email : _profile.email;
        if (_object._newpass) {
          _profile._newpass = _object._newpass;
        }
        new RequestUtils()._custom('profile', JSON.stringify(_profile), function(result, params) {
          location.reload();
        }, {
          pos : DOMUtils.findPos(this)
        });
      } else {
        _p_user.account = (_object._account) ? _object._account : _p_user.account;
        _p_user.email = (_object._email) ? _object._email : _p_user.email;
        if (_object._newpass) {
          _p_user._newpass = _object._newpass;
        }
        
        new RequestUtils()._custom('profile2', JSON.stringify({obj1: _profile, obj2: _p_user}), function(result, params) {
          location.reload();
        }, {
          pos : DOMUtils.findPos(this)
        });
      }
//      
    }
  // -->
</script>